const fs = require('fs');
const path = require('path');
const logger = require('./log4jsLogger');//配置文件
//创建日志代理方法，覆盖console
function createLogProxy (logLevel, logger) {
    return (...param) => {
        logger[logLevel](...param);
    };
}
console.log = createLogProxy('debug', logger);
console.info = createLogProxy('info', logger);
console.warn = createLogProxy('warn', logger);
console.error = createLogProxy('error', logger);

/*（工具类)os.networkInterfaces()获取本机电脑IP*/
function getIPAddress() {
    let interfaces = require('os').networkInterfaces();
    for (var devName in interfaces) {
        var iface = interfaces[devName];
        for (var i = 0; i < iface.length; i++) {
            let alias = iface[i];
            if (alias.family === 'IPv4' && alias.address !== '127.0.0.1' && !alias.internal) {
                return alias.address
            }
        }
    }
}

module.exports ={ getIPAddress }
